{itemplate 'public/header'}
<div class="page" id="page-delivery-order">
	<header class="bar bar-nav common-bar-nav">
		<a class="icon pull-left icon icon-arrow-left back hide"></a>
		<h1 class="title">乘客订单{if $status == 3 && $config_takeout['order']['auto_refresh'] == 1}(<span id="time">10</span>秒后自动刷新){/if}</h1>
	</header>
	{itemplate 'public/nav'}
	<div class="content infinite-scroll js-infinite" data-href="{php echo imurl('delivery/order/takeout/more', array('status' => $status))}" data-distance="50" data-min="{$min}" data-container=".order-list-container" data-tpl="tpl-takeout-order">
		<div class="buttons-tab">
			<a href="{php echo imurl('delivery/order/takeout/list', array('status' => 3));}" class="button {if $status == 3}active{/if}">待抢</a>
			<a href="{php echo imurl('delivery/order/takeout/list', array('status' => 7));}" class="button {if $status == 7}active{/if}">待乘车</a>
			<a href="{php echo imurl('delivery/order/takeout/list', array('status' => 4));}" class="button {if $status == 4}active{/if}">乘车中</a>
			<a href="{php echo imurl('delivery/order/takeout/list', array('status' => 5));}" class="button {if $status == 5}active{/if}">乘车成功</a>
			<a href="{php echo imurl('delivery/order/takeout/list', array('status' => 6));}" class="button {if $status == 6}active{/if}">乘车失败</a>
		</div>
		{if empty($orders)}
		<div class="no-data">
			<div class="bg"></div>
			<p>没有任何订单哦～</p>
		</div>
		{else}
		<div class="order-list">
			{if $status == 3}
			<ul>
				{loop $orders $order}
				<li class="row delivery-wait">
					{if $order['delivery_type'] == 1}
						<div class="delivery-type bg-danger">店内</div>
					{else}
						<div class="delivery-type bg-success">平台</div>
					{/if}
					<div class="order-ls-info col-80">
						<p>编号: <b class="color-danger" style="font-size: .8rem;">#{$order['serial_sn']}</b></p>
						<p>乘车路线: {$stores[$order['sid']]['title']}</p>
						<!--<p>下车地点: {$stores[$order['sid']]['address']}</p>-->
						<p>上车地点: {$order['address']}</p>
						<p>下车地点: {$order['note']}</p>
						<!--<p>乘车时间: {php echo date('Y-m-d H:i:s', $order['addtime'])}</p>-->
						<p>乘车时间: {php echo $order['delivery_day']} {php echo $order['delivery_time']}</p>
						{if $order['delivery_type'] == 2}
							<p>车主佣金: {$order['plateform_deliveryer_fee']}元 <span>上车收取</span></p>
							{if $order['pay_type'] == 'delivery'}
								<p class="color-danger">本单需收取顾客: {$order['final_fee']}元</p>
							{/if}
						{/if}
					</div>
					<div class="order-pay-info {$order['pay_type_class']}"></div>
					<div class="order-ls-btn col-20">
						<a href="{php echo imurl('delivery/order/takeout/collect', array('id' => $order['id']))}" class="js-post" data-confirm="{if $order['delivery_type'] == 1}该订单是店内单, 确定接单吗?{else}该订单是平台单, 乘客到达目的地后将获得{$order['plateform_deliveryer_fee']}元拼车费, 确定接单吗{/if}">抢</a>
					</div>
				</li>
				{/loop}
			</ul>
			{else}
			<ul class="order-list-container">
				{loop $orders $order}
					<li class="delivery-others border-1px-tb">
						{if $order['delivery_type'] == 1}
							<div class="delivery-type bg-danger">店内</div>
						{else}
							<div class="delivery-type bg-success">平台</div>
						{/if}
						<!--<a class="order-ls-info external" href="{php echo imurl('delivery/order/takeout/detail', array('id' => $order['id']));}">-->
						<a class="order-ls-info external" >
							<div class="order-ls-tl">编号: <b class="order-serial-sn">#{$order['serial_sn']}</b><span class="{$delivery_status[$order['delivery_status']]['color']}">{$delivery_status[$order['delivery_status']]['text']}</span></div>
							<div class="order-ls-date">{php echo date('Y-m-d H:i:s', $order['addtime']);}<span>乘车人:{$order['username']}</span></div>
							<div class="order-ls-dl border-1px-tb">
								<div class="row">
									<div class="col-25">上车地点:</div>
									<div class="col-75 align-right">{$stores[$order['sid']]['address']}</div>
								</div>
								<div class="row">
									<div class="col-25">下车地点:</div>
									<!--<div class="col-75 align-right">{$order['address']}</div>-->
									<div class="col-75 align-right">{$order['note']}</div>
								</div>
								<div class="row">
									<div class="col-25">手机　号:</div>
									<div class="col-75 align-right">{$order['mobile']}</div>
								</div>
								{if $order['delivery_type'] == 2 && $order['pay_type'] == 'delivery'}
									<div class="row color-danger">
										<div class="col-25">本单需收取顾客:</div>
										<div class="col-75 align-right">{$order['final_fee']}元</div>
									</div>
								{/if}
							</div>
							<!--<div class="order-ls-sum">共{$order['num']}人，合计：¥{$order['final_fee']}</div>-->
							<div class="order-ls-sum">共{$order['num']}人，车主佣金：¥{$order['plateform_deliveryer_fee']}<span>上车收取</span></div>
						</a>
						<div class="order-pay-info {$order['pay_type_class']}"></div>
						{if $order['delivery_status'] == 7}
							<div class="order-ls-btn border-1px-t">
								<a href="tel:{$stores[$order['sid']]['telephone']}" class="border-1px-r">呼叫乘客</a>
								<a href="{php echo imurl('delivery/order/takeout/instore', array('id' => $order['id']))}" data-confirm="确定已到达?" class="js-post">确认到达</a>
							</div>
						{elseif $order['delivery_status'] == 4}
							<div class="order-ls-btn border-1px-t">
								<a href="tel:{$order['mobile']}" class="border-1px-r">呼叫乘客</a>
								<a href="{php echo imurl('delivery/order/takeout/notice', array('id' => $order['id']));}" data-confirm="确定通知乘车人你已到达送餐地址吗?" class="js-post border-1px-r">微信通知</a>
								<a href="{php echo imurl('delivery/order/takeout/success', array('id' => $order['id']));}" data-confirm="{if $order['pay_type'] == 'delivery' && $order['delivery_type'] == 2}'本单属于货到付款单,请收取顾客{$order['final_fee']}元{else}确认送达目的地?{/if}" class="js-post">确认送达</a>
							</div>
						{/if}
					</li>
					{/loop}
				</ul>
			{/if}
			<div class="infinite-scroll-preloader hide">
				<div class="preloader"></div>
			</div>
		</div>
		{/if}
	</div>
</div>
<script id="tpl-takeout-order" type="text/html">
	<{# for(var i = 0, len = d.length; i < len; i++){ }>
	<li class="delivery-others border-1px-tb">
		<{# if(d[i].delivery_type == 1){ }>
		<div class="delivery-type bg-danger">店内</div>
		<{# } else { }>
		<div class="delivery-type bg-success">平台</div>
		<{# } }>
		<div class="order-ls-info">
			<div class="order-ls-tl">编号: <b class="order-serial-sn">#<{d[i].serial_sn}></b><span class="<{d[i].status_color}>"><{d[i].status_cn}></span></div>
			<div class="order-ls-date"><{d[i].addtime_cn}><span>乘车人:<{d[i].username}></span></div>
			<div class="order-ls-dl">
				<div class="row">
					<div class="col-25">上车地点:</div>
					<div class="col-75 align-right"><{d[i].store.address}></div>
				</div>
				<div class="row">
					<div class="col-25">下车地点:</div>
					<!--<div class="col-75 align-right"><{d[i].address}></div>-->
					<div class="col-75 align-right"><{d[i].note}></div>
				</div>
				<div class="row">
					<div class="col-25">手机　号:</div>
					<div class="col-75 align-right"><{d[i].mobile}></div>
				</div>
			</div>
			<!--<div class="order-ls-sum">共<{d[i].num}>人，合计：¥<{d[i].final_fee}></div>-->
			<div class="order-ls-sum">共<{d[i].num}>人，车主佣金：¥<{d[i].plateform_deliveryer_fee}><span>上车收取</span></div>
		</div>
		<{# if(d[i].delivery_status == 7){ }>
			<div class="order-ls-btn border-1px-t">
				<a href="tel:<{d[i].store.telephone}>" class="border-1px-r">呼叫乘客</a>
				<a href="{php echo imurl('delivery/order/takeout/instore')}&id=<{d[i].id}>" data-confirm="确定已到达?" class="js-post">确认到达</a>
			</div>
		<{# } else if(d[i].delivery_status == 4){ }>
			<div class="order-ls-btn border-1px-t">
				<a href="tel:<{d[i].mobile}>" class="border-1px-r">呼叫乘客</a>
				<a href="{php echo imurl('delivery/order/takeout/notice');}&id=<{d[i].id}>" data-confirm="确定通知乘车人你已到达送餐地址吗?" class="js-post border-1px-r">微信通知</a>
				<a href="{php echo imurl('delivery/order/takeout/success');}&id=<{d[i].id}>"  data-confirm="<{# if(d[i].pay_type == 'delivery' && d[i].delivery_type == 2 ){ }>本单属于货到付款单,请收取顾客<{d[i].final_fee}>元<{# } else { }>确认送达目的地?<{# } }>" class="js-post">确认送达</a>
			</div>
		<{# } }>
	</li>
	<{# } }>
</script>
<script>
$(function(){
	//自动刷新
	{if $status == 3 && $config_takeout['order']['auto_refresh'] == 1}
		setInterval(function(){
			var time = parseInt($('#time').html());
			if(time >= 1) {
				time--;
				$('#time').html(time);
			} else {
				location.reload();
			}
		}, 1000);
	{/if}
});
</script>
{itemplate 'public/footer'}